<!DOCTYPE html>

<html>
	<head>
		<meta charset="UTF-8">
		<title>Ajax</title>
		
	</head>
	<body>
		<input id="name" type="text"/>
		<input type="button" value="点击执行ajax" onclick="doAjax()"/>
		<script  src="/static/jquery/jquery-2.0.3.js"></script>
		<script type="text/javascript">
			function doAjax(){
				var temp=$('#name').val()
				$.ajax({
					//url末尾的 '/'不能省略 
					url:'/app04/ajax/',
					type:'POST',
					data:{data:temp},
					success:function(arg){
							//console.log('success');
							console.log(arg);
							var jsonObj=$.parseJSON(arg);
							console.log(jsonObj);
							console.log(jsonObj.status);
							console.log(jsonObj.msg);
							console.log(jsonObj.data);
							$('#name').val(jsonObj.msg);
						},
					error:function(){
							console.log('failed');
						}
				});
				//alert(temp)
			}
		</script>
	</body>
</html>